package com.ks.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 元对象处理程序
 *
 * @author KingAusten
 * @date 2022/08/17 18:03:37
 */
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler{

    /**
     * 插入填充
     *
     * @param metaObject 元对象
     */
    @Override
    public void insertFill(MetaObject metaObject){

        this.strictInsertFill(metaObject,"gmtCreate",LocalDateTime :: now,LocalDateTime.class);
    }

    /**
     * 更新填充
     *
     * @param metaObject 元对象
     */
    @Override
    public void updateFill(MetaObject metaObject){

        this.strictUpdateFill(metaObject,"gmtModified",LocalDateTime :: now,LocalDateTime.class);
    }

}
